<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let obj = {}
        let input = document.getElementById('input')
        let span = document.getElementById('span')

        input.addEventListener('keyup', function (e) {
            obj.text = e.target.value
        })

        
        Object.defineProperty(obj, 'text', {
            configurable: true,
            enumerable: true,
            get() {
                console.log('获取数据了')
            },
            set(newVal) {
                console.log('数据更新了')
                input.value = newVal
                span.innerHTML = newVal
            }
        })
    </script>
</body>

</html>